home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / libamiga / syscalls.c < prev   
C/C++ Source or Header  |  1989-12-29  |  2KB  |  147 lines

  1. /*
  2.  *    This is an Amiga version of the Unix system calls that need
  3.  *    to be implemented in order to link the C-News package...
  4.  */
  5.  
  6. #include <stdio.h>                /* For file_i/o stuff */
  7. #include <stdlib.h>                /* Declarations of ctime(), etc */
  8. #ifdef MCH_AMIGA
  9. #  include <time.h>                /* For time_t */
  10. #else
  11. #  include <sys/types.h>        /* ditto */
  12. #endif
  13. #include <libraries/dos.h>        /* For TICKS */
  14.  
  15. extern struct Process *FindTask();
  16.  
  17. static FILE *syslogf = 0;
  18.  
  19. /* VARARGS1 */
  20. sysfile(fmt, args)
  21. char *fmt;
  22. int args;
  23. {
  24.     static char first_time = TRUE;
  25.  
  26.     if (first_time) {
  27.         first_time = 0;
  28.         syslogf = fopen("ram:syscall_log", "w");
  29.     }
  30.     if (syslogf) {
  31.         vfprintf(syslogf, fmt, &args);
  32.         fflush(syslogf);
  33.     }
  34.     return( 0 );
  35. }
  36.  
  37. short getpid()
  38. {
  39.     return( (short) ((long) FindTask(0L) & 0x7FFFL) );
  40. }
  41.  
  42. static short    old_uid  = 0, old_gid  = 0;
  43. static short    old_euid = 0, old_egid = 0;
  44.  
  45. short getuid()
  46. {
  47.     return( old_uid );
  48. }
  49.  
  50. short getgid()
  51. {
  52.     return( old_gid );
  53. }
  54.  
  55. short geteuid()
  56. {
  57.     return( old_euid );
  58. }
  59.  
  60. short getegid()
  61. {
  62.     return( old_egid );
  63. }
  64.  
  65. short setuid(new_uid)
  66. short new_uid;
  67. {
  68.     short xxx;
  69.  
  70.     xxx = old_uid;
  71.     old_uid = new_uid;
  72.     return( xxx );
  73. }
  74.  
  75. short setgid(new_gid)
  76. short new_gid;
  77. {
  78.     short xxx;
  79.  
  80.     xxx = old_gid;
  81.     old_gid = new_gid;
  82.     return( xxx );
  83. }
  84.  
  85. chown(fname, uid)
  86. char *fname;
  87. short uid;
  88. {
  89.     sysfile("Supposed to chown on `%s' to `%hd'\n", fname, uid);
  90.     return( 0 );
  91. }
  92.  
  93. link(from, to)
  94. char *from, *to;
  95. {
  96.     sysfile("Supposed to link from `%s' to `%s'\n", from, to);
  97.     return( 0 );
  98. }
  99.  
  100. #ifndef MCH_AMIGA        /* If not on Manx, ... */
  101. sleep(sec)
  102. long sec;
  103. {
  104.     Delay( sec * TICKS_PER_SECOND );
  105.     return( 0 );
  106. }
  107. #endif /* MCH_AMIGA */
  108.  
  109. short umask(msk)
  110. short msk;
  111. {
  112.     static short old_msk = 0;
  113.     short xxx;
  114.  
  115.     xxx = old_msk;
  116.     old_msk = msk;
  117.     return( xxx );
  118. }
  119.  
  120. int alarm(secs)
  121. int secs;
  122. {
  123.     if (secs) {
  124.         time_t tm;
  125.         (void) time(&tm);
  126.         sysfile("Alarm(%d) has been called at %s", secs, ctime(&tm));
  127.     }
  128.     return( 0 );
  129. }
  130.  
  131. #ifndef MCH_AMIGA
  132. void mktemp(p)
  133. register char *p;
  134. {
  135.     register char *tmp;
  136.     register int count = 0;
  137.     FILE *fp;
  138.  
  139.     tmp = p + strlen(p);
  140.     while (*--tmp == 'X')
  141.         count++;
  142.     sprintf(tmp+1, "%0*.*ld", count, count, (long) getpid());
  143.     if (fp = fopen( p, "w" ))
  144.         fclose(fp);
  145. }
  146. #endif /* MCH_AMIGA */
  147.